package cn.wh.bean;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author wanghao
 * @Date 2022-08-16 22:48
 * @Description: bean 工厂注入bean 获取bean
 */
public class BeanFactory {

    private Map<String, BeanDefinition> map = new HashMap<>();

    /**
     * 根据名称获取bean
     *
     * @param name
     * @return
     */
    public Object getBean(String name) {
        return map.get(name).getBean();
    }

    /**
     * 注册bean
     */
    public void registerBean(String name, BeanDefinition beanDefinition) {
        map.put(name, beanDefinition);
    }


}
